package android.support.v4.media;

import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.BadParcelableException;
import android.os.Binder;
import android.os.Build.VERSION;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import android.os.Messenger;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.Parcelable.Creator;
import android.os.RemoteException;
import android.support.v4.media.session.MediaSessionCompat;
import android.support.v4.media.session.MediaSessionCompat.Token;
import android.support.v4.os.ResultReceiver;
import android.text.TextUtils;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.annotation.RestrictTo;
import androidx.media.MediaBrowserServiceCompat;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map.Entry;
import o.ds;
import o.fh;
import o.ln;
import o.q;
import o.r;
import o.t;
import o.u;

public final class MediaBrowserCompat {
    static final boolean ॱ = Log.isLoggable("MediaBrowserCompat", 3);
    private final b ˏ;

    static class CustomActionResultReceiver extends ResultReceiver {
        private final String ˋ;
        private final Bundle ˏ;
        private final c ॱॱ;

        public void ˋ(int i, Bundle bundle) {
            if (this.ॱॱ != null) {
                MediaSessionCompat.ˏ(bundle);
                switch (i) {
                    case -1:
                        this.ॱॱ.ॱ(this.ˋ, this.ˏ, bundle);
                        return;
                    case 0:
                        this.ॱॱ.ˋ(this.ˋ, this.ˏ, bundle);
                        return;
                    case 1:
                        this.ॱॱ.ˊ(this.ˋ, this.ˏ, bundle);
                        return;
                    default:
                        Log.w("MediaBrowserCompat", "Unknown result code: " + i + " (extras=" + this.ˏ + ", resultData=" + bundle + ")");
                        return;
                }
            }
        }
    }

    static class ItemReceiver extends ResultReceiver {
        private final String ˋ;
        private final e ˏ;

        public void ˋ(int i, Bundle bundle) {
            MediaSessionCompat.ˏ(bundle);
            if (i == 0 && bundle != null && bundle.containsKey(MediaBrowserServiceCompat.KEY_MEDIA_ITEM)) {
                Parcelable parcelable = bundle.getParcelable(MediaBrowserServiceCompat.KEY_MEDIA_ITEM);
                if (parcelable == null || (parcelable instanceof MediaItem)) {
                    this.ˏ.ˋ((MediaItem) parcelable);
                    return;
                } else {
                    this.ˏ.ˋ(this.ˋ);
                    return;
                }
            }
            this.ˏ.ˋ(this.ˋ);
        }
    }

    public static class MediaItem implements Parcelable {
        public static final Creator<MediaItem> CREATOR = new Creator<MediaItem>() {
            public /* synthetic */ Object createFromParcel(Parcel parcel) {
                return ˏ(parcel);
            }

            public /* synthetic */ Object[] newArray(int i) {
                return ˎ(i);
            }

            public MediaItem ˏ(Parcel parcel) {
                return new MediaItem(parcel);
            }

            public MediaItem[] ˎ(int i) {
                return new MediaItem[i];
            }
        };
        private final MediaDescriptionCompat ˋ;
        private final int ˎ;

        @RestrictTo({androidx.annotation.RestrictTo.d.ˊ})
        @Retention(RetentionPolicy.SOURCE)
        public @interface Flags {
        }

        public static MediaItem ˋ(Object obj) {
            if (obj == null || VERSION.SDK_INT < 21) {
                return null;
            }
            return new MediaItem(MediaDescriptionCompat.ˊ(o.q.c.ˊ(obj)), o.q.c.ॱ(obj));
        }

        public static List<MediaItem> ˎ(List<?> list) {
            if (list == null || VERSION.SDK_INT < 21) {
                return null;
            }
            List<MediaItem> arrayList = new ArrayList(list.size());
            for (Object ˋ : list) {
                arrayList.add(ˋ(ˋ));
            }
            return arrayList;
        }

        public MediaItem(@NonNull MediaDescriptionCompat mediaDescriptionCompat, int i) {
            if (mediaDescriptionCompat == null) {
                throw new IllegalArgumentException("description cannot be null");
            } else if (TextUtils.isEmpty(mediaDescriptionCompat.ˎ())) {
                throw new IllegalArgumentException("description must have a non-empty media id");
            } else {
                this.ˎ = i;
                this.ˋ = mediaDescriptionCompat;
            }
        }

        MediaItem(Parcel parcel) {
            this.ˎ = parcel.readInt();
            this.ˋ = (MediaDescriptionCompat) MediaDescriptionCompat.CREATOR.createFromParcel(parcel);
        }

        public int describeContents() {
            return 0;
        }

        public void writeToParcel(Parcel parcel, int i) {
            parcel.writeInt(this.ˎ);
            this.ˋ.writeToParcel(parcel, i);
        }

        public String toString() {
            StringBuilder stringBuilder = new StringBuilder("MediaItem{");
            stringBuilder.append("mFlags=").append(this.ˎ);
            stringBuilder.append(", mDescription=").append(this.ˋ);
            stringBuilder.append('}');
            return stringBuilder.toString();
        }
    }

    static class SearchResultReceiver extends ResultReceiver {
        private final o ʻ;
        private final Bundle ˋ;
        private final String ˏ;

        public void ˋ(int i, Bundle bundle) {
            MediaSessionCompat.ˏ(bundle);
            if (i == 0 && bundle != null && bundle.containsKey(MediaBrowserServiceCompat.KEY_SEARCH_RESULTS)) {
                Parcelable[] parcelableArray = bundle.getParcelableArray(MediaBrowserServiceCompat.KEY_SEARCH_RESULTS);
                List list = null;
                if (parcelableArray != null) {
                    List arrayList = new ArrayList();
                    for (Parcelable parcelable : parcelableArray) {
                        arrayList.add((MediaItem) parcelable);
                    }
                    list = arrayList;
                }
                this.ʻ.ॱ(this.ˏ, this.ˋ, list);
                return;
            }
            this.ʻ.ˎ(this.ˏ, this.ˋ);
        }
    }

    public static class a {
        d ˎ;
        final Object ॱ;

        class b implements o.q.d {
            final /* synthetic */ a ˏ;

            b(a aVar) {
                this.ˏ = aVar;
            }

            public void ॱ() {
                if (this.ˏ.ˎ != null) {
                    this.ˏ.ˎ.ˎ();
                }
                this.ˏ.ॱ();
            }

            public void ˋ() {
                if (this.ˏ.ˎ != null) {
                    this.ˏ.ˎ.ˊ();
                }
                this.ˏ.ˏ();
            }

            public void ˊ() {
                if (this.ˏ.ˎ != null) {
                    this.ˏ.ˎ.ॱ();
                }
                this.ˏ.ˎ();
            }
        }

        interface d {
            void ˊ();

            void ˎ();

            void ॱ();
        }

        public a() {
            if (VERSION.SDK_INT >= 21) {
                this.ॱ = q.ˏ(new b(this));
            } else {
                this.ॱ = null;
            }
        }

        public void ॱ() {
        }

        public void ˏ() {
        }

        public void ˎ() {
        }

        void ॱ(d dVar) {
            this.ˎ = dVar;
        }
    }

    interface b {
        @NonNull
        Token ʼ();

        void ˋ();

        void ˏ();
    }

    public static abstract class c {
        public void ˊ(String str, Bundle bundle, Bundle bundle2) {
        }

        public void ˋ(String str, Bundle bundle, Bundle bundle2) {
        }

        public void ॱ(String str, Bundle bundle, Bundle bundle2) {
        }
    }

    static class d extends Handler {
        private final WeakReference<h> ˎ;
        private WeakReference<Messenger> ˏ;

        d(h hVar) {
            this.ˎ = new WeakReference(hVar);
        }

        public void handleMessage(Message message) {
            if (this.ˏ != null && this.ˏ.get() != null && this.ˎ.get() != null) {
                Bundle data = message.getData();
                MediaSessionCompat.ˏ(data);
                h hVar = (h) this.ˎ.get();
                Messenger messenger = (Messenger) this.ˏ.get();
                try {
                    Bundle bundle;
                    switch (message.what) {
                        case 1:
                            bundle = data.getBundle("data_root_hints");
                            MediaSessionCompat.ˏ(bundle);
                            hVar.ॱ(messenger, data.getString("data_media_item_id"), (Token) data.getParcelable("data_media_session_token"), bundle);
                            return;
                        case 2:
                            hVar.ˊ(messenger);
                            return;
                        case 3:
                            bundle = data.getBundle("data_options");
                            MediaSessionCompat.ˏ(bundle);
                            Bundle bundle2 = data.getBundle("data_notify_children_changed_options");
                            MediaSessionCompat.ˏ(bundle2);
                            hVar.ˏ(messenger, data.getString("data_media_item_id"), data.getParcelableArrayList("data_media_item_list"), bundle, bundle2);
                            return;
                        default:
                            Log.w("MediaBrowserCompat", "Unhandled message: " + message + "\n  Client version: " + 1 + "\n  Service version: " + message.arg1);
                            return;
                    }
                } catch (BadParcelableException e) {
                    Log.e("MediaBrowserCompat", "Could not unparcel the data.");
                    if (message.what == 1) {
                        hVar.ˊ(messenger);
                    }
                }
                Log.e("MediaBrowserCompat", "Could not unparcel the data.");
                if (message.what == 1) {
                    hVar.ˊ(messenger);
                }
            }
        }

        void ˊ(Messenger messenger) {
            this.ˏ = new WeakReference(messenger);
        }
    }

    public static abstract class e {
        final Object ˋ;

        class c implements o.r.b {
            final /* synthetic */ e ˊ;

            c(e eVar) {
                this.ˊ = eVar;
            }

            public void ॱ(Parcel parcel) {
                if (parcel == null) {
                    this.ˊ.ˋ(null);
                    return;
                }
                parcel.setDataPosition(0);
                MediaItem mediaItem = (MediaItem) MediaItem.CREATOR.createFromParcel(parcel);
                parcel.recycle();
                this.ˊ.ˋ(mediaItem);
            }

            public void ˊ(@NonNull String str) {
                this.ˊ.ˋ(str);
            }
        }

        public e() {
            if (VERSION.SDK_INT >= 23) {
                this.ˋ = r.ˋ(new c(this));
            } else {
                this.ˋ = null;
            }
        }

        public void ˋ(MediaItem mediaItem) {
        }

        public void ˋ(@NonNull String str) {
        }
    }

    interface h {
        void ˊ(Messenger messenger);

        void ˏ(Messenger messenger, String str, List list, Bundle bundle, Bundle bundle2);

        void ॱ(Messenger messenger, String str, Token token, Bundle bundle);
    }

    static class f implements b, h {
        private final ds<String, n> ʻ = new ds();
        int ʼ = 1;
        d ʽ;
        final ComponentName ˊ;
        private Bundle ˊॱ;
        final d ˋ = new d(this);
        final a ˎ;
        final Bundle ˏ;
        private Bundle ˏॱ;
        private Token ͺ;
        final Context ॱ;
        private String ॱˊ;
        k ॱॱ;
        Messenger ᐝ;

        class d implements ServiceConnection {
            final /* synthetic */ f ˏ;

            d(f fVar) {
                this.ˏ = fVar;
            }

            public void onServiceConnected(final ComponentName componentName, final IBinder iBinder) {
                ˊ(new Runnable(this) {
                    final /* synthetic */ d ˊ;

                    public void run() {
                        if (MediaBrowserCompat.ॱ) {
                            Log.d("MediaBrowserCompat", "MediaServiceConnection.onServiceConnected name=" + componentName + " binder=" + iBinder);
                            this.ˊ.ˏ.ˎ();
                        }
                        if (this.ˊ.ˊ("onServiceConnected")) {
                            this.ˊ.ˏ.ॱॱ = new k(iBinder, this.ˊ.ˏ.ˏ);
                            this.ˊ.ˏ.ᐝ = new Messenger(this.ˊ.ˏ.ˋ);
                            this.ˊ.ˏ.ˋ.ˊ(this.ˊ.ˏ.ᐝ);
                            this.ˊ.ˏ.ʼ = 2;
                            try {
                                if (MediaBrowserCompat.ॱ) {
                                    Log.d("MediaBrowserCompat", "ServiceCallbacks.onConnect...");
                                    this.ˊ.ˏ.ˎ();
                                }
                                this.ˊ.ˏ.ॱॱ.ˋ(this.ˊ.ˏ.ॱ, this.ˊ.ˏ.ᐝ);
                            } catch (RemoteException e) {
                                Log.w("MediaBrowserCompat", "RemoteException during connect for " + this.ˊ.ˏ.ˊ);
                                if (MediaBrowserCompat.ॱ) {
                                    Log.d("MediaBrowserCompat", "ServiceCallbacks.onConnect...");
                                    this.ˊ.ˏ.ˎ();
                                }
                            }
                        }
                    }
                });
            }

            public void onServiceDisconnected(final ComponentName componentName) {
                ˊ(new Runnable(this) {
                    final /* synthetic */ d ˊ;

                    public void run() {
                        if (MediaBrowserCompat.ॱ) {
                            Log.d("MediaBrowserCompat", "MediaServiceConnection.onServiceDisconnected name=" + componentName + " this=" + this + " mServiceConnection=" + this.ˊ.ˏ.ʽ);
                            this.ˊ.ˏ.ˎ();
                        }
                        if (this.ˊ.ˊ("onServiceDisconnected")) {
                            this.ˊ.ˏ.ॱॱ = null;
                            this.ˊ.ˏ.ᐝ = null;
                            this.ˊ.ˏ.ˋ.ˊ(null);
                            this.ˊ.ˏ.ʼ = 4;
                            this.ˊ.ˏ.ˎ.ˏ();
                        }
                    }
                });
            }

            private void ˊ(Runnable runnable) {
                if (Thread.currentThread() == this.ˏ.ˋ.getLooper().getThread()) {
                    runnable.run();
                } else {
                    this.ˏ.ˋ.post(runnable);
                }
            }

            boolean ˊ(String str) {
                if (this.ˏ.ʽ == this && this.ˏ.ʼ != 0 && this.ˏ.ʼ != 1) {
                    return true;
                }
                if (!(this.ˏ.ʼ == 0 || this.ˏ.ʼ == 1)) {
                    Log.i("MediaBrowserCompat", str + " for " + this.ˏ.ˊ + " with mServiceConnection=" + this.ˏ.ʽ + " this=" + this);
                }
                return false;
            }
        }

        public f(Context context, ComponentName componentName, a aVar, Bundle bundle) {
            if (context == null) {
                throw new IllegalArgumentException("context must not be null");
            } else if (componentName == null) {
                throw new IllegalArgumentException("service component must not be null");
            } else if (aVar == null) {
                throw new IllegalArgumentException("connection callback must not be null");
            } else {
                this.ॱ = context;
                this.ˊ = componentName;
                this.ˎ = aVar;
                this.ˏ = bundle == null ? null : new Bundle(bundle);
            }
        }

        public void ˏ() {
            if (this.ʼ == 0 || this.ʼ == 1) {
                this.ʼ = 2;
                this.ˋ.post(new Runnable(this) {
                    final /* synthetic */ f ˊ;

                    {
                        this.ˊ = r1;
                    }

                    public void run() {
                        if (this.ˊ.ʼ != 0) {
                            this.ˊ.ʼ = 2;
                            if (MediaBrowserCompat.ॱ && this.ˊ.ʽ != null) {
                                throw new RuntimeException("mServiceConnection should be null. Instead it is " + this.ˊ.ʽ);
                            } else if (this.ˊ.ॱॱ != null) {
                                throw new RuntimeException("mServiceBinderWrapper should be null. Instead it is " + this.ˊ.ॱॱ);
                            } else if (this.ˊ.ᐝ != null) {
                                throw new RuntimeException("mCallbacksMessenger should be null. Instead it is " + this.ˊ.ᐝ);
                            } else {
                                Intent intent = new Intent(MediaBrowserServiceCompat.SERVICE_INTERFACE);
                                intent.setComponent(this.ˊ.ˊ);
                                this.ˊ.ʽ = new d(this.ˊ);
                                boolean z = false;
                                try {
                                    z = this.ˊ.ॱ.bindService(intent, this.ˊ.ʽ, 1);
                                } catch (Exception e) {
                                    Log.e("MediaBrowserCompat", "Failed binding to service " + this.ˊ.ˊ);
                                }
                                if (!z) {
                                    this.ˊ.ˊ();
                                    this.ˊ.ˎ.ˎ();
                                }
                                if (MediaBrowserCompat.ॱ) {
                                    Log.d("MediaBrowserCompat", "connect...");
                                    this.ˊ.ˎ();
                                }
                            }
                        }
                    }
                });
                return;
            }
            throw new IllegalStateException("connect() called while neigther disconnecting nor disconnected (state=" + ˏ(this.ʼ) + ")");
        }

        public void ˋ() {
            this.ʼ = 0;
            this.ˋ.post(new Runnable(this) {
                final /* synthetic */ f ˋ;

                {
                    this.ˋ = r1;
                }

                public void run() {
                    if (this.ˋ.ᐝ != null) {
                        try {
                            this.ˋ.ॱॱ.ˋ(this.ˋ.ᐝ);
                        } catch (RemoteException e) {
                            Log.w("MediaBrowserCompat", "RemoteException during connect for " + this.ˋ.ˊ);
                        }
                    }
                    int i = this.ˋ.ʼ;
                    this.ˋ.ˊ();
                    if (i != 0) {
                        this.ˋ.ʼ = i;
                    }
                    if (MediaBrowserCompat.ॱ) {
                        Log.d("MediaBrowserCompat", "disconnect...");
                        this.ˋ.ˎ();
                    }
                }
            });
        }

        void ˊ() {
            if (this.ʽ != null) {
                this.ॱ.unbindService(this.ʽ);
            }
            this.ʼ = 1;
            this.ʽ = null;
            this.ॱॱ = null;
            this.ᐝ = null;
            this.ˋ.ˊ(null);
            this.ॱˊ = null;
            this.ͺ = null;
        }

        public boolean ॱ() {
            return this.ʼ == 3;
        }

        @NonNull
        public Token ʼ() {
            if (ॱ()) {
                return this.ͺ;
            }
            throw new IllegalStateException("getSessionToken() called while not connected(state=" + this.ʼ + ")");
        }

        public void ॱ(Messenger messenger, String str, Token token, Bundle bundle) {
            if (!ˋ(messenger, "onConnect")) {
                return;
            }
            if (this.ʼ != 2) {
                Log.w("MediaBrowserCompat", "onConnect from service while mState=" + ˏ(this.ʼ) + "... ignoring");
                return;
            }
            this.ॱˊ = str;
            this.ͺ = token;
            this.ˏॱ = bundle;
            this.ʼ = 3;
            if (MediaBrowserCompat.ॱ) {
                Log.d("MediaBrowserCompat", "ServiceCallbacks.onConnect...");
                ˎ();
            }
            this.ˎ.ॱ();
            try {
                for (Entry entry : this.ʻ.entrySet()) {
                    String str2 = (String) entry.getKey();
                    n nVar = (n) entry.getValue();
                    List ˏ = nVar.ˏ();
                    List ॱ = nVar.ॱ();
                    for (int i = 0; i < ˏ.size(); i++) {
                        this.ॱॱ.ˏ(str2, ((l) ˏ.get(i)).ˋ, (Bundle) ॱ.get(i), this.ᐝ);
                    }
                }
            } catch (RemoteException e) {
                Log.d("MediaBrowserCompat", "addSubscription failed with RemoteException.");
            }
        }

        public void ˊ(Messenger messenger) {
            Log.e("MediaBrowserCompat", "onConnectFailed for " + this.ˊ);
            if (!ˋ(messenger, "onConnectFailed")) {
                return;
            }
            if (this.ʼ != 2) {
                Log.w("MediaBrowserCompat", "onConnect from service while mState=" + ˏ(this.ʼ) + "... ignoring");
                return;
            }
            ˊ();
            this.ˎ.ˎ();
        }

        public void ˏ(Messenger messenger, String str, List list, Bundle bundle, Bundle bundle2) {
            if (ˋ(messenger, "onLoadChildren")) {
                if (MediaBrowserCompat.ॱ) {
                    Log.d("MediaBrowserCompat", "onLoadChildren for " + this.ˊ + " id=" + str);
                }
                n nVar = (n) this.ʻ.get(str);
                if (nVar != null) {
                    l ˏ = nVar.ˏ(bundle);
                    if (ˏ == null) {
                        return;
                    }
                    if (bundle == null) {
                        if (list == null) {
                            ˏ.ˏ(str);
                            return;
                        }
                        this.ˊॱ = bundle2;
                        ˏ.ˋ(str, list);
                        this.ˊॱ = null;
                    } else if (list == null) {
                        ˏ.ˎ(str, bundle);
                    } else {
                        this.ˊॱ = bundle2;
                        ˏ.ˎ(str, list, bundle);
                        this.ˊॱ = null;
                    }
                } else if (MediaBrowserCompat.ॱ) {
                    Log.d("MediaBrowserCompat", "onLoadChildren for id that isn't subscribed id=" + str);
                }
            }
        }

        private static String ˏ(int i) {
            switch (i) {
                case 0:
                    return "CONNECT_STATE_DISCONNECTING";
                case 1:
                    return "CONNECT_STATE_DISCONNECTED";
                case 2:
                    return "CONNECT_STATE_CONNECTING";
                case 3:
                    return "CONNECT_STATE_CONNECTED";
                case 4:
                    return "CONNECT_STATE_SUSPENDED";
                default:
                    return "UNKNOWN/" + i;
            }
        }

        private boolean ˋ(Messenger messenger, String str) {
            if (this.ᐝ == messenger && this.ʼ != 0 && this.ʼ != 1) {
                return true;
            }
            if (!(this.ʼ == 0 || this.ʼ == 1)) {
                Log.i("MediaBrowserCompat", str + " for " + this.ˊ + " with mCallbacksMessenger=" + this.ᐝ + " this=" + this);
            }
            return false;
        }

        void ˎ() {
            Log.d("MediaBrowserCompat", "MediaBrowserCompat...");
            Log.d("MediaBrowserCompat", "  mServiceComponent=" + this.ˊ);
            Log.d("MediaBrowserCompat", "  mCallback=" + this.ˎ);
            Log.d("MediaBrowserCompat", "  mRootHints=" + this.ˏ);
            Log.d("MediaBrowserCompat", "  mState=" + ˏ(this.ʼ));
            Log.d("MediaBrowserCompat", "  mServiceConnection=" + this.ʽ);
            Log.d("MediaBrowserCompat", "  mServiceBinderWrapper=" + this.ॱॱ);
            Log.d("MediaBrowserCompat", "  mCallbacksMessenger=" + this.ᐝ);
            Log.d("MediaBrowserCompat", "  mRootId=" + this.ॱˊ);
            Log.d("MediaBrowserCompat", "  mMediaSessionToken=" + this.ͺ);
        }
    }

    @RequiresApi(21)
    static class j implements b, h, d {
        private Bundle ʻ;
        protected k ʼ;
        protected Messenger ʽ;
        protected final Bundle ˊ;
        final Context ˋ;
        protected final Object ˎ;
        protected final d ˏ = new d(this);
        protected int ॱ;
        private Token ॱॱ;
        private final ds<String, n> ᐝ = new ds();

        j(Context context, ComponentName componentName, a aVar, Bundle bundle) {
            this.ˋ = context;
            this.ˊ = bundle != null ? new Bundle(bundle) : new Bundle();
            this.ˊ.putInt("extra_client_version", 1);
            aVar.ॱ(this);
            this.ˎ = q.ˋ(context, componentName, aVar.ॱ, this.ˊ);
        }

        public void ˏ() {
            q.ˎ(this.ˎ);
        }

        public void ˋ() {
            if (!(this.ʼ == null || this.ʽ == null)) {
                try {
                    this.ʼ.ˏ(this.ʽ);
                } catch (RemoteException e) {
                    Log.i("MediaBrowserCompat", "Remote error unregistering client messenger.");
                }
            }
            q.ॱ(this.ˎ);
        }

        @NonNull
        public Token ʼ() {
            if (this.ॱॱ == null) {
                this.ॱॱ = Token.ˏ(q.ˋ(this.ˎ));
            }
            return this.ॱॱ;
        }

        public void ˎ() {
            Bundle ˊ = q.ˊ(this.ˎ);
            if (ˊ != null) {
                this.ॱ = ˊ.getInt("extra_service_version", 0);
                IBinder ˏ = fh.ˏ(ˊ, "extra_messenger");
                if (ˏ != null) {
                    this.ʼ = new k(ˏ, this.ˊ);
                    this.ʽ = new Messenger(this.ˏ);
                    this.ˏ.ˊ(this.ʽ);
                    try {
                        this.ʼ.ˏ(this.ˋ, this.ʽ);
                    } catch (RemoteException e) {
                        Log.i("MediaBrowserCompat", "Remote error registering client messenger.");
                    }
                }
                u ˋ = o.u.e.ˋ(fh.ˏ(ˊ, "extra_session_binder"));
                if (ˋ != null) {
                    this.ॱॱ = Token.ˎ(q.ˋ(this.ˎ), ˋ);
                }
            }
        }

        public void ˊ() {
            this.ʼ = null;
            this.ʽ = null;
            this.ॱॱ = null;
            this.ˏ.ˊ(null);
        }

        public void ॱ() {
        }

        public void ॱ(Messenger messenger, String str, Token token, Bundle bundle) {
        }

        public void ˊ(Messenger messenger) {
        }

        public void ˏ(Messenger messenger, String str, List list, Bundle bundle, Bundle bundle2) {
            if (this.ʽ == messenger) {
                n nVar = (n) this.ᐝ.get(str);
                if (nVar != null) {
                    l ˏ = nVar.ˏ(bundle);
                    if (ˏ == null) {
                        return;
                    }
                    if (bundle == null) {
                        if (list == null) {
                            ˏ.ˏ(str);
                            return;
                        }
                        this.ʻ = bundle2;
                        ˏ.ˋ(str, list);
                        this.ʻ = null;
                    } else if (list == null) {
                        ˏ.ˎ(str, bundle);
                    } else {
                        this.ʻ = bundle2;
                        ˏ.ˎ(str, list, bundle);
                        this.ʻ = null;
                    }
                } else if (MediaBrowserCompat.ॱ) {
                    Log.d("MediaBrowserCompat", "onLoadChildren for id that isn't subscribed id=" + str);
                }
            }
        }
    }

    @RequiresApi(23)
    static class i extends j {
        i(Context context, ComponentName componentName, a aVar, Bundle bundle) {
            super(context, componentName, aVar, bundle);
        }
    }

    @RequiresApi(26)
    static class g extends i {
        g(Context context, ComponentName componentName, a aVar, Bundle bundle) {
            super(context, componentName, aVar, bundle);
        }
    }

    static class k {
        private Bundle ˋ;
        private Messenger ॱ;

        public k(IBinder iBinder, Bundle bundle) {
            this.ॱ = new Messenger(iBinder);
            this.ˋ = bundle;
        }

        void ˋ(Context context, Messenger messenger) throws RemoteException {
            Bundle bundle = new Bundle();
            bundle.putString("data_package_name", context.getPackageName());
            bundle.putBundle("data_root_hints", this.ˋ);
            ˎ(1, bundle, messenger);
        }

        void ˋ(Messenger messenger) throws RemoteException {
            ˎ(2, null, messenger);
        }

        void ˏ(String str, IBinder iBinder, Bundle bundle, Messenger messenger) throws RemoteException {
            Bundle bundle2 = new Bundle();
            bundle2.putString("data_media_item_id", str);
            fh.ˏ(bundle2, "data_callback_token", iBinder);
            bundle2.putBundle("data_options", bundle);
            ˎ(3, bundle2, messenger);
        }

        void ˏ(Context context, Messenger messenger) throws RemoteException {
            Bundle bundle = new Bundle();
            bundle.putString("data_package_name", context.getPackageName());
            bundle.putBundle("data_root_hints", this.ˋ);
            ˎ(6, bundle, messenger);
        }

        void ˏ(Messenger messenger) throws RemoteException {
            ˎ(7, null, messenger);
        }

        private void ˎ(int i, Bundle bundle, Messenger messenger) throws RemoteException {
            Message obtain = Message.obtain();
            obtain.what = i;
            obtain.arg1 = 1;
            obtain.setData(bundle);
            obtain.replyTo = messenger;
            this.ॱ.send(obtain);
        }
    }

    public static abstract class l {
        WeakReference<n> ˊ;
        final IBinder ˋ = new Binder();
        final Object ˏ;

        class d implements o.q.a {
            final /* synthetic */ l ˎ;

            d(l lVar) {
                this.ˎ = lVar;
            }

            public void ॱ(@NonNull String str, List<?> list) {
                n nVar = this.ˎ.ˊ == null ? null : (n) this.ˎ.ˊ.get();
                if (nVar == null) {
                    this.ˎ.ˋ(str, MediaItem.ˎ(list));
                    return;
                }
                List ˎ = MediaItem.ˎ(list);
                List ˏ = nVar.ˏ();
                List ॱ = nVar.ॱ();
                for (int i = 0; i < ˏ.size(); i++) {
                    Bundle bundle = (Bundle) ॱ.get(i);
                    if (bundle == null) {
                        this.ˎ.ˋ(str, ˎ);
                    } else {
                        this.ˎ.ˎ(str, ˋ(ˎ, bundle), bundle);
                    }
                }
            }

            public void ॱ(@NonNull String str) {
                this.ˎ.ˏ(str);
            }

            List<MediaItem> ˋ(List<MediaItem> list, Bundle bundle) {
                if (list == null) {
                    return null;
                }
                int i = bundle.getInt("android.media.browse.extra.PAGE", -1);
                int i2 = bundle.getInt("android.media.browse.extra.PAGE_SIZE", -1);
                if (i == -1 && i2 == -1) {
                    return list;
                }
                int i3 = i2 * i;
                int i4 = i3 + i2;
                if (i < 0 || i2 < 1 || i3 >= list.size()) {
                    return Collections.emptyList();
                }
                if (i4 > list.size()) {
                    i4 = list.size();
                }
                return list.subList(i3, i4);
            }
        }

        class e extends d implements o.t.c {
            final /* synthetic */ l ॱ;

            e(l lVar) {
                this.ॱ = lVar;
                super(lVar);
            }

            public void ˊ(@NonNull String str, List<?> list, @NonNull Bundle bundle) {
                this.ॱ.ˎ(str, MediaItem.ˎ(list), bundle);
            }

            public void ॱ(@NonNull String str, @NonNull Bundle bundle) {
                this.ॱ.ˎ(str, bundle);
            }
        }

        public l() {
            if (VERSION.SDK_INT >= 26) {
                this.ˏ = t.ˎ(new e(this));
            } else if (VERSION.SDK_INT >= 21) {
                this.ˏ = q.ˏ(new d(this));
            } else {
                this.ˏ = null;
            }
        }

        public void ˋ(@NonNull String str, @NonNull List<MediaItem> list) {
        }

        public void ˎ(@NonNull String str, @NonNull List<MediaItem> list, @NonNull Bundle bundle) {
        }

        public void ˏ(@NonNull String str) {
        }

        public void ˎ(@NonNull String str, @NonNull Bundle bundle) {
        }
    }

    static class n {
        private final List<l> ˋ = new ArrayList();
        private final List<Bundle> ˏ = new ArrayList();

        public List<Bundle> ॱ() {
            return this.ˏ;
        }

        public List<l> ˏ() {
            return this.ˋ;
        }

        public l ˏ(Bundle bundle) {
            for (int i = 0; i < this.ˏ.size(); i++) {
                if (ln.ॱ((Bundle) this.ˏ.get(i), bundle)) {
                    return (l) this.ˋ.get(i);
                }
            }
            return null;
        }
    }

    public static abstract class o {
        public void ॱ(@NonNull String str, Bundle bundle, @NonNull List<MediaItem> list) {
        }

        public void ˎ(@NonNull String str, Bundle bundle) {
        }
    }

    public MediaBrowserCompat(Context context, ComponentName componentName, a aVar, Bundle bundle) {
        if (VERSION.SDK_INT >= 26) {
            this.ˏ = new g(context, componentName, aVar, bundle);
        } else if (VERSION.SDK_INT >= 23) {
            this.ˏ = new i(context, componentName, aVar, bundle);
        } else if (VERSION.SDK_INT >= 21) {
            this.ˏ = new j(context, componentName, aVar, bundle);
        } else {
            this.ˏ = new f(context, componentName, aVar, bundle);
        }
    }

    public void ˏ() {
        this.ˏ.ˏ();
    }

    public void ˊ() {
        this.ˏ.ˋ();
    }

    @NonNull
    public Token ˋ() {
        return this.ˏ.ʼ();
    }
}
